<template>
  <div id="o2oAppoinment">
    <div class="top">
      <div class="top_l">{{ store_reserve_info.div_name }}</div>
      <div class="top_r" @click="tapGet">领取</div>
    </div>
    <div class="bottom">
      <div class="txt">{{ store_reserve_info.content }}</div>
    </div>
    <!-- 底部导航 -->
    <div class="o2oappoinmentnav set-pc-style" v-if="store_reserve_info.bottom_nav_open == 1">
      <div class="flex">
        <a :href="'tel:' + store_reserve_info.store_mobile">
          <i class="iconfont icon-dianhua"></i>
          <div class="txt">电话</div>
        </a>
      </div>
      <div class="flex" @click="toservice(store_reserve_info.customer_service)">
        <i class="iconfont icon-comment"></i>
        <div class="txt">{{ store_reserve_info.leave_message_name }}</div>
      </div>
      <div class="btn" @click="tapGet">预约体验</div>
    </div>
    <van-popup v-model="show" :style="{ background: 'transparent' }" :close-on-click-overlay="false">
      <div class="freeBox">
        <div class="free">
          <div class="title title_top">{{ store_reserve_info.div_name }}</div>
          <div class="contenBox">
            <div class="title">{{ store_reserve_info.div_name }}</div>
            <div class="contenTxt contenTxt_b">{{ store_reserve_info.content }}</div>
          </div>
          <div class="tips">
            <span>成功预约后商户将通过电话联系您</span>
            <span v-if="store_reserve_info.member_mobile">{{ store_reserve_info.member_mobile }}</span>
          </div>
          <div class="inpPhone" v-if="!store_reserve_info.member_mobile">
            <van-field v-model="mobile" placeholder="请输入您的手机号"></van-field>
          </div>
          <div class="btn btn_s" @click="tapAppoinment" v-if="!store_reserve_info.is_reserve">立即预约</div>
          <div class="btn" v-if="store_reserve_info.is_reserve">您已预约</div>
        </div>
        <i class="iconfont icon-adsystem_icon_cancle" @click="closePopup"></i>
      </div>
    </van-popup>
  </div>
</template>
<script>
export default {
  props: {
    store_reserve_info: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      show: false,
      mobile: ""
    };
  },
  methods: {
    toservice(customer_service){
      if(!customer_service.service){
        this.$toast('未设置客服链接');
        return
      }
      window.location.href = customer_service.service;
    },
    closePopup() {
      this.show = false;
    },
    tapGet() {
      this.show = true;
    },
    async tapAppoinment() {
      let json = {
        form: {
          store_id: this.$route.params.store_id,
          mobile: this.store_reserve_info.member_mobile ? this.store_reserve_info.member_mobile : this.mobile
        }
      };
      let { data, result, msg } = await $http.post("plugin.store-cashier.frontend.store.store.store-reserve-info", json);
      if (result == 1) {
        this.$emit("update")
      }
      this.$dialog.alert({ message: msg });
    }
  }
};
</script>
<style lang="scss" scoped>
.freeBox {
  width: 18.75rem;
  display: flex;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  .free {
    background: linear-gradient(180deg, #f8e2d5 0%, #ffffff 100%);
    border-radius: 0.94rem 0.94rem 0.94rem 0.94rem;
    padding-bottom: 0.94rem;
    .title_top {
      margin: 0 0.63rem;
      padding: 0.94rem 0;
    }
    .title {
      font-weight: bold;
      font-size: 0.94rem;
      color: #973c0b;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .inpPhone {
      margin: 0.63rem;
      border-radius: 0.75rem 0.75rem 0.75rem 0.75rem;
      border: 0.03rem solid #d6d6dc;
      padding-left: 0.75rem;
      padding-right: 0.75rem;
      height: 2.5rem;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      .van-cell {
        padding: 0;
        background: transparent;
      }
    }
    .tips {
      font-size: 0.75rem;
      color: #aaaab3;
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      padding-left: 1.38rem;
      box-sizing: border-box;
      margin-top: 0.56rem;
    }
    .btn {
      width: 16.25rem;
      height: 2.5rem;
      background: #d6d6dc;
      border-radius: 1.88rem 1.88rem 1.88rem 1.88rem;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 500;
      font-size: 0.94rem;
      color: #ffffff;
      margin: 0 auto;
      margin-top: 1.31rem;
    }
    .btn_s {
      background: #f15353;
    }
    .contenBox {
      overflow: hidden;
      background: #ffffff;
      padding: 0.84rem 0.63rem 0.84rem 0.75rem;
      margin: 0 0.63rem;
      box-sizing: border-box;
      border-radius: 0.75rem 0.75rem 0.75rem 0.75rem;
      text-align: left;
      overflow: hidden;
      .contenTxt_b {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-top: 0.3rem;
        font-size: 0.81rem;
        color: #973c0b;
      }
    }
  }
  .icon-adsystem_icon_cancle {
    font-size: 2rem;
    color: #d6d6dc;
    margin-top: 1.25rem;
  }
}
#o2oAppoinment {
  margin: 0.72rem 0.75rem;
  overflow: hidden;
  background: linear-gradient(175deg, #f1ccb7 0%, #f8e2d5 100%);
  border-radius: 0.94rem 0.94rem 0.94rem 0.94rem;
  padding: 0.63rem;
  box-sizing: border-box;
  .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
    .top_l {
      font-weight: bold;
      font-size: 1.13rem;
      color: #973c0b;
      flex: 1;
      text-align: left;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .top_r {
      width: 4rem;
      height: 1.75rem;
      background: linear-gradient(104deg, #e6a883 0%, #c45d25 100%);
      border-radius: 1.25rem 1.25rem 1.25rem 1.25rem;
      font-weight: 500;
      font-size: 0.94rem;
      color: #ffffff;
      display: flex;
      justify-content: center;
      align-items: center;
      line-height: 1rem;
      flex-shrink: 0;
    }
  }
  .bottom {
    margin-top: 0.56rem;
    width: 100%;
    overflow: hidden;
    background: #ffffff;
    border-radius: 0.63rem;
    padding: 0.69rem;
    box-sizing: border-box;
    .txt {
      text-align: left;
      font-weight: 400;
      font-size: 0.81rem;
      color: #973c0b;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

.o2oappoinmentnav {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3.06rem;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 1.5rem;
  padding-right: 0.75rem;
  box-sizing: border-box;
  z-index: 1;
  .flex {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .txt {
      font-size: 0.75rem;
      color: #6e6e79;
    }
    .iconfont {
      font-weight: bold;
      color: #000;
      margin-bottom: 0.1rem;
    }
  }

  .btn {
    width: 13.41rem;
    height: 2.5rem;
    background: #f15353;
    border-radius: 1.28rem 1.28rem 1.28rem 1.28rem;
    font-weight: 500;
    font-size: 0.94rem;
    color: #ffffff;
    text-align: center;
    line-height: 2.5rem;
  }
}
</style>
